39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_analog_in.h"
52#include "drv_i2c_master.h"
74#define FORCECELL_R6_KOHM 2.7
75#define FORCECELL_GAIN ( ( 100 / FORCECELL_R6_KOHM ) + 1 )
76#define FORCECELL_SENSITIVITY_V_V 0.025
77#define FORCECELL_FULL_SCALE_N 30
83#define FORCECELL_NUM_CONVERSIONS 100
89#define FORCECELL_TIMEOUT_MS 2000
95#define FORCECELL_ADC_RESOLUTION 0x0FFF
96#define FORCECELL_VREF_3V3 3.3
97#define FORCECELL_VREF_5V 5.0
98#define FORCECELL_VREF FORCECELL_VREF_3V3
105#define FORCECELL_SET_DEV_ADDR 0x4D
123#define FORCECELL_MAP_MIKROBUS( cfg, mikrobus ) \
124 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
125 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
126 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
forcecell_return_value_t
Force Cell Click return value data.
Definition forcecell.h:183
@ FORCECELL_OK
Definition forcecell.h:184
@ FORCECELL_ERROR
Definition forcecell.h:185
forcecell_drv_t
Force Cell Click driver selector.
Definition forcecell.h:136
@ FORCECELL_DRV_SEL_ADC
Definition forcecell.h:137
@ FORCECELL_DRV_SEL_I2C
Definition forcecell.h:138
err_t forcecell_read_raw_adc(forcecell_t *ctx, uint16_t *raw_adc)
Force Cell read raw ADC value function.
err_t forcecell_init(forcecell_t *ctx, forcecell_cfg_t *cfg)
Force Cell initialization function.
err_t forcecell_calib_offset(forcecell_t *ctx)
Force Cell calib offset function.
err_t forcecell_read_voltage_avg(forcecell_t *ctx, uint16_t num_conv, float *voltage_avg)
Force Cell read average voltage level function.
void forcecell_drv_interface_sel(forcecell_cfg_t *cfg, forcecell_drv_t drv_sel)
Force Cell driver interface setup function.
void forcecell_cfg_setup(forcecell_cfg_t *cfg)
Force Cell configuration object setup function.
err_t forcecell_read_force(forcecell_t *ctx, float *force)
Force Cell read force function.
err_t forcecell_set_vref(forcecell_t *ctx, float vref)
Force Cell set vref function.
err_t forcecell_read_voltage(forcecell_t *ctx, float *voltage)
Force Cell read voltage level function.
Force Cell Click configuration object.
Definition forcecell.h:163
analog_in_resolution_t resolution
Definition forcecell.h:168
float vref
Definition forcecell.h:169
uint32_t i2c_speed
Definition forcecell.h:171
pin_name_t scl
Definition forcecell.h:165
pin_name_t sda
Definition forcecell.h:166
forcecell_drv_t drv_sel
Definition forcecell.h:174
pin_name_t an
Definition forcecell.h:164
uint8_t i2c_address
Definition forcecell.h:172
Force Cell Click context object.
Definition forcecell.h:147
float vref
Definition forcecell.h:152
i2c_master_t i2c
Definition forcecell.h:149
float zero_force_offset
Definition forcecell.h:154
uint8_t slave_address
Definition forcecell.h:151
forcecell_drv_t drv_sel
Definition forcecell.h:153
analog_in_t adc
Definition forcecell.h:148